<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-once语法(了解)</title>
</head>
<body>
  <div id="app" v-once>
    <!--1. 指令: v-once-->
    <h2 v-once> 
      当前计数: {{ message }} <br>
      <span> 当前数量: {{counter}} </span> <!--子元素也会只渲染一次-->
    </h2>
    
    <button @click="changeMessage"> 修改message </button>
  </div>
  
  <script src="../lib/vue.js"></script>
  <script>
    // 使用vue
    const app = Vue.createApp({
      data: function(){
        return {
          message: "Hello v-once"
          , counter: 100
        }
      }
      ,methods: {
        changeMessage: function(){
          this.message = "hello message"
          , this.counter = 200
          , console.log(this.message)
        }
      }
    }
    )
    // 挂载 
    app.mount("#app")
  </script>

</body>
</html>
